/*
 * @Author: szx
 * @Date: 2022-02-18 13:27:37
 * @LastEditTime: 2022-02-18 13:29:52
 * @Description:
 * @FilePath: \leetcode\200-299\206\206_2.js
 */
function ListNode(val, next) {
    this.val = val === undefined ? -1 : val;
    this.next = next === undefined ? null : next;
}

/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var reverseList = function (head) {
    let prev = null;
    let cur = head;
    while (cur != null) {
        const next = cur.next;
        cur.next = prev;
        prev = cur;
        cur = next;
    }
    return prev;
};
